<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>News system v1</title>


<link rel="stylesheet" type="text/css" href="style.css">


</head>

<body>



<div id="exCenter">
    <div id="exHeader">
        <center><h1><a href="index.php">Update news system v1</a></h1></center>
    </div>
    <div id="exContent">
        <div id="exLeftColumn">
            <p>
		
		<table>
		<tr>
		<td width="750">
		
			<?PHP
			$con=mysqli_connect("localhost","root","","bd_news");
			// Check connection
			if (mysqli_connect_errno()) {
			  echo "Failed to connect to MySQL: " . mysqli_connect_error();
			}


				$id_update = mysqli_real_escape_string($con, $_GET['id_update']);


			$result = mysqli_query($con,"SELECT id_news, title, description, maintext, date, rating, id_user  FROM `news` where id_news=$id_update");

			while($row = mysqli_fetch_array($result)) {
			  $update[0] = $row['id_news']; 
			  $update[1] = $row['title'];
			  $update[2] = $row['description'];
			  $update[3] = $row['maintext'];
			  $update[4] = $row['date'];
			  $update[5] = $row['id_user'];
			  /*
			  echo "<br>".$row['title'];
			  echo "<br>". $row['description'];
			  echo "<br>". $row['maintext'];
			  echo "<br>".$row['date'];
			 echo "<br>". $row['rating'];
			  echo "<br>". $row['id_user'];
			*/
			}



			mysqli_close($con);	
			?>



			<form name="update_form" action="update_news_mysql.php" method="post">

			
			
			
			
			
			
			
			
			
			<table>
				<tr>
					<td width="100">
					ID:
					</td>
					<td width="650">
					<input type="text" name="id_update" maxlength="20" size="20" value="<?php echo $update[0]; ?>" style="width: 100px;" /> 
					</td>
				</tr>
				
				<tr>
					<td width="100">
					Title:
					</td>
					<td width="650">
					<input type="text" name="title" maxlength="20" size="20" value="<?php echo $update[1]; ?>" style="width: 550px;" /> 
					</td>
				</tr>
				
				<tr>
					<td width="100">
					Description:
					</td>
					<td width="650">
					<textarea type="text" name="description"  size="20"  style="width: 550px; height: 210px"><?php echo $update[2]; ?></textarea>
					</td>
				</tr>
				
				<tr>
					<td>
					Maintext:
					</td>
					<td>
					<textarea type="text" name="maintext"  size="20"  style="width: 550px; height: 210px"><?php echo $update[3]; ?></textarea>
					</td>
				</tr>
				
				<tr>
					<td>
					DATE: 
					</td>
					<td>
					
					
					<input name="date" type="date" maxlength="20" size="20"  value="<?php echo $update[4]; ?>"/>
					</td>
				</tr>
				
				<tr>
					<td>
					ID_User: 
					</td>
					<td>
					
					<input type="text" name="id_user" maxlength="20" size="20" style="width: 100px;" value="<?php echo $update[5]; ?>" disabled="yes"/> 
					
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<center>
							<input type="submit" name="add_usr" value="Updatuj newsa"/>
							</form>
						</center>
					</td>
					<td>
					</td>
				</tr>
			
				
			</table>
			
		
		
		
			


					
		
		</td >
		</tr>
		</table>	
    </p>
            
            
            
            
        </div>
       <div id="exRightColumn">
		
			
			<center><b>Quick menu:</b></center> <br><br>
			<a href="index.php">- Strona główna</a><Br>
			<a href="newsmyadm.php">- NewsMyAdm</a><Br>
			<a href="add_news.php">- Dodaj nowy news</a><br>            
            <a href="logout.php">- Wyloguj</a><Br><Br>
			
            <center>
			<a href="newsmyadm.php">ANULUJ EDYTOWANIE</a>
            </center>
            
            
            
        </div>
        <div class="exClear"></div>
    </div>
    <div id="exFooter">	    
	    <center>
	        <p><a href="newsmyadm.php">admin © 2014 Basinsky</a></p>
	    </center>    
    </div>
</div>




</body>

</html>
